package com.xxl.javawork;

/**
 *三角形类，计算三角形的周长和面积
 * @author xiaxinlin
 * @version 1.0
 * @since jdk1.8
 * @date 2021/1/9 22:44
 */
public class TriangleCal {

    private double sideA;
    private double sideB;
    private double sideC;

    /**
     * 三角形构造器
     *
     * @param sideA 三角形边长A
     * @param sideB 三角形边长A
     * @param sideC 三角形边长A
     * @author xiaxinlin
     * @creed: Talk is cheap,show me the code
     * @date 2021/1/9
     */
    public TriangleCal(double sideA, double sideB, double sideC) {
        this.sideA = sideA;
        this.sideB = sideB;
        this.sideC = sideC;
    }

    public double getSideA() {
        return sideA;
    }

    public void setSideA(double sideA) {
        this.sideA = sideA;
    }

    public double getSideB() {
        return sideB;
    }

    public void setSideB(double sideB) {
        this.sideB = sideB;
    }

    public double getSideC() {
        return sideC;
    }

    public void setSideC(double sideC) {
        this.sideC = sideC;
    }

    /**
     * 计算三角形面积
     *
     * @return double 三角形面积，小数点保留3位
     * @author xiaxinlin
     * @creed: Talk is cheap,show me the code
     * @date 2021/1/9
     */
    public double getArea(){
        double p = sideA+sideB+sideC;
        return Math.round(Math.sqrt(p*(p-sideA)*(p-sideB)*(p-sideC))*1000)/1000.0;
    }

    /**
     * 计算三角形周长
     *
     * @return double 三角形周长
     * @author xiaxinlin
     * @creed: Talk is cheap,show me the code
     * @date 2021/1/9
     */
    public double getGirth(){
        return sideA+sideB+sideC;
    }
}
